<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <title>问卷调查登录注册</title>
    <!-- <link rel="stylesheet" href="css/style.css"> -->







<style>
    *, *:before, *:after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Open Sans', Helvetica, Arial, sans-serif;
    background: #ededed;
}

input, button {
    border: none;
    outline: none;
    background: none;
    font-family: 'Open Sans', Helvetica, Arial, sans-serif;
}

.tip {
    font-size: 20px;
    margin: 40px auto 50px;
    text-align: center;
}

.content {
    overflow: hidden;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 900px;
    height: 550px;
    margin: -300px 0 0 -450px;
    background: #fff;
}

.form {
    position: relative;
    width: 640px;
    height: 100%;
    transition: -webkit-transform 0.6s ease-in-out;
    transition: transform 0.6s ease-in-out;
    transition: transform 0.6s ease-in-out, -webkit-transform 0.6s ease-in-out;
    padding: 50px 30px 0;
}

.sub-cont {
    overflow: hidden;
    position: absolute;
    left: 640px;
    top: 0;
    width: 900px;
    height: 100%;
    padding-left: 260px;
    background: #fff;
    transition: -webkit-transform 0.6s ease-in-out;
    transition: transform 0.6s ease-in-out;
    transition: transform 0.6s ease-in-out, -webkit-transform 0.6s ease-in-out;
}

.content.s--signup .sub-cont {
    -webkit-transform: translate3d(-640px, 0, 0);
    transform: translate3d(-640px, 0, 0);
}

button {
    display: block;
    margin: 0 auto;
    width: 260px;
    height: 36px;
    border-radius: 30px;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
}

.img {
    overflow: hidden;
    z-index: 2;
    position: absolute;
    left: 0;
    top: 0;
    width: 260px;
    height: 100%;
    padding-top: 360px;
}

.img:before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 900px;
    height: 100%;
    background-image: url(../images/bg.jpg);
    background-size: cover;
    transition: -webkit-transform 0.6s ease-in-out;
    transition: transform 0.6s ease-in-out;
    transition: transform 0.6s ease-in-out, -webkit-transform 0.6s ease-in-out;
}

.img:after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
}

.content.s--signup .img:before {
    -webkit-transform: translate3d(640px, 0, 0);
    transform: translate3d(640px, 0, 0);
}

.img__text {
    z-index: 2;
    position: absolute;
    left: 0;
    top: 50px;
    width: 100%;
    padding: 0 20px;
    text-align: center;
    color: #fff;
    transition: -webkit-transform 0.6s ease-in-out;
    transition: transform 0.6s ease-in-out;
    transition: transform 0.6s ease-in-out, -webkit-transform 0.6s ease-in-out;
}

.img__text h2 {
    margin-bottom: 10px;
    font-weight: normal;
}

.img__text p {
    font-size: 14px;
    line-height: 1.5;
}

.content.s--signup .img__text.m--up {
    -webkit-transform: translateX(520px);
    transform: translateX(520px);
}
.img__text.m--in {
    -webkit-transform: translateX(-520px);
    transform: translateX(-520px);
}

.content.s--signup .img__text.m--in {
    -webkit-transform: translateX(0);
    transform: translateX(0);
}

.img__btn {
    overflow: hidden;
    z-index: 2;
    position: relative;
    width: 100px;
    height: 36px;
    margin: 0 auto;
    background: transparent;
    color: #fff;
    text-transform: uppercase;
    font-size: 15px;
    cursor: pointer;
}
.img__btn:after {
    content: '';
    z-index: 2;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border: 2px solid #fff;
    border-radius: 30px;
}

.img__btn span {
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    transition: -webkit-transform 0.6s;
    transition: transform 0.6s;
    transition: transform 0.6s, -webkit-transform 0.6s;
}

.img__btn span.m--in {
    -webkit-transform: translateY(-72px);
    transform: translateY(-72px);
}

.content.s--signup .img__btn span.m--in {
    -webkit-transform: translateY(0);
    transform: translateY(0);
}

.content.s--signup .img__btn span.m--up {
    -webkit-transform: translateY(72px);
    transform: translateY(72px);
}

h2 {
    width: 100%;
    font-size: 26px;
    text-align: center;
}

label {
    display: block;
    width: 260px;
    margin: 25px auto 0;
    text-align: center;
}

label span {
    font-size: 12px;
    color: #909399;
    text-transform: uppercase;
}

input {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding-bottom: 5px;
    font-size: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.4);
    text-align: center;
}

.forgot-pass {
    margin-top: 15px;
    text-align: center;
    font-size: 12px;
    color: #cfcfcf;
}

.forgot-pass a {
    color: #cfcfcf;
}

.submit {
    margin-top: 40px;
    margin-bottom: 20px;
    background: #d4af7a;
    text-transform: uppercase;
}

.fb-btn {
    border: 2px solid #d3dae9;
    color: #8fa1c7;
}
.fb-btn span {
    font-weight: bold;
    color: #455a81;
}

.sign-in {
    transition-timing-function: ease-out;
}
.content.s--signup .sign-in {
    transition-timing-function: ease-in-out;
    transition-duration: 0.6s;
    -webkit-transform: translate3d(640px, 0, 0);
    transform: translate3d(640px, 0, 0);
}

.sign-up {
    -webkit-transform: translate3d(-900px, 0, 0);
    transform: translate3d(-900px, 0, 0);
}
.content.s--signup .sign-up {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
}
</style>

</head>








<body>


    <div class="content">
        <form action="" id="form">
            <div class="form sign-in">
                <h2>欢迎回来</h2>
                <label>
                    <span id="s_username">用户名</span>
                    <input type="text" name="username" id="username" />
                </label>
                <label>
                    <span id="s_password">密码</span>
                    <input type="password" name="password" id="password" />
                </label>
                <p class="forgot-pass"><a href="javascript:">忘记密码？</a></p>
                <button type="button" id="login" class="submit" onclick="">登 录</button>

            </div>
            <div class="sub-cont">
                <div class="img">
                    <div class="img__text m--up">
                        <h2>还未注册？</h2>
                        <p>立即注册，发现大量机会！</p>
                    </div>
                    <div class="img__text m--in">
                        <h2>已有帐号？</h2>
                        <p>有帐号就登录吧，好久不见了！</p>
                    </div>
                    <div class="img__btn">
                        <span class="m--up">注 册</span>
                        <span class="m--in">登 录</span>
                    </div>
                </div>
               

        </form>
        <form action="" id="form1">
            <div class="form sign-up">
                <h2>立即注册</h2>
                <label>
                    <span id="s_newusername">用户名</span>
                    <input type="text" name="newusername" id="newusername" />
                </label>
                <label>
                    <span id="s_newpassword">密码</span>
                    <input type="password" name="newpassword" id="newpassword" />
                </label>
                <label>
                    <span id="s_configpassword">确认密码</span>
                    <input type="password" name="configpassword" id="configpassword" />
                </label>
                <button type="button" id="register" class="submit" onclick="checkUsername4()">注 册</button>

            </div>
    </div>
    </form>

    </div>

    <!-- <script src="js/script.js"></script> -->


    <div style="text-align:center;">

    </div>



<script>

document.querySelector('.img__btn').addEventListener('click', function() {
    document.querySelector('.content').classList.toggle('s--signup')
})
</script>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="/manage/js/questionnaires.js"></script>
<script type="text/javascript">
    let newusername=$("#newusername")
    let newpwd=$("#newpassword")
    $("#register").click(function(){
        console.log("开始")
        if(newusername.val().length==0||newpwd.val().length==0){
            alert("用户或密码不能为空")
            return;
        }
        var getPhone1=newusername.val()
        var getPwd1=newpwd.val()
        var data={
            newusername:getPhone1,
            newpassword:getPwd1
        }
        console.log(data)
        $.ajax({
            type:"POST",
            url:"http://127.0.0.1:8081/register",
            data:data,
            success:res=>{
                console.log(res)
                if(res.code==200){
                    alert(res.msg)
                    window.location.href="/"
                }else if(res.code==201){
                    alert(res.msg)
                    window.location.href="/"
                }else{
                    alert(res.msg)
                    window.location.href="/"
                }
            },
            error:err=>{
                console.log(err)
            }
        })
    })
</script>


    <script>







            let username=$("#username")
            let pwd=$("#password")
            $("#login").click(function(){
                console.log("开始")
                if(username.val().length==0||pwd.val().length==0){
                    alert("用户或密码不能为空")
                    return;
                }
                var getPhone=username.val()
                var getPwd=pwd.val()
                var data={
                    username:getPhone,
                    password:getPwd
                }
                console.log(data)
                $.ajax({
                    type:"POST",
                    url:"http://127.0.0.1:8081/login",
                    data:data,
                    success:res=>{
                        console.log(res)
                        if(res.code==200){
                            alert(res.msg)
                            window.location.href="/index"
                        }else if(res.code==201){
                            alert(res.msg)
                            window.location.href="/index"
                        }else if(res.code==202){
                            alert(res.msg)
                            window.location.href="/"
                        }else if(res.code==204){

                            window.location.href="/"
                        }
                        else{
                            alert(res.msg)
                            window.location.href="/"
                        }
                    },
                    error:err=>{
                        console.log(err)
                    }
                })
            })



















        window.onload = function () {

            document.getElementById("form").onsubmit = function () {

                return checkUsername() && checkpassword() && checkUsername1() && checkpassword1() &&
                    checkpassword2();
            }

            document.getElementById("username").onblur = checkUsername;
            document.getElementById("password").onblur = checkpassword;
            document.getElementById("newusername").onblur = checkUsername1;
            document.getElementById("newpassword").onblur = checkpassword1;
            document.getElementById("configpassword").onblur = checkpassword2;
        }

        function checkUsername() {

            var username = document.getElementById("username").value;

            var reg_username = /^\w{3,12}$/;

            var flag = reg_username.test(username);

            var s_username = document.getElementById("s_username");
            if (flag) {

                s_username.innerHTML = "<img width='30' height='20' src='../images/对勾提示.jpg'>"
            } else {

                s_username.innerHTML = "用户名格式有误";
            }
            return flag;
        }

        function checkpassword() {

            var password = document.getElementById("password").value;

            var reg_password = /^\w{6,12}$/;

            var flag = reg_password.test(password);

            var s_password = document.getElementById("s_password");
            if (flag) {

                s_password.innerHTML = "<img width='30' height='20' src='../images/对勾提示.jpg'>"
            } else {

                s_password.innerHTML = "密码格式有误";
            }
        }





        function checkUsername1() {

            var newusername = document.getElementById("newusername").value;

            var reg_username1 = /^\w{3,12}$/;

            var flag1 = reg_username1.test(newusername);

            var s_newusername = document.getElementById("s_newusername");
            if (flag1) {

                s_newusername.innerHTML = "<img width='30' height='20' src='../images/对勾提示.jpg'>"
            } else {

                s_newusername.innerHTML = "用户名格式有误";
            }
            return flag1;
        }

        function checkpassword1() {

            var newpassword = document.getElementById("newpassword").value;

            var reg_password1 = /^\w{6,12}$/;

            var flag1 = reg_password1.test(newpassword);

            var s_newpassword = document.getElementById("s_newpassword");
            if (flag1) {

                s_newpassword.innerHTML = "<img width='30' height='20' src='../images/对勾提示.jpg'>"
            } else {

                s_newpassword.innerHTML = "密码格式有误";
            }
        }

        function checkpassword2() {

            var configpassword = document.getElementById("configpassword").value;

            var reg_password2 = /^\w{6,12}$/;

            var flag1 = reg_password2.test(configpassword);

            var s_configpassword = document.getElementById("s_configpassword");
            if (flag1) {

                s_configpassword.innerHTML = "<img width='30' height='20' src='../images/对勾提示.jpg'>"
            } else {

                s_configpassword.innerHTML = "密码格式有误";
            }
        }





        function checkUsername3() {

            var username = document.getElementById("username").value;

            var reg_username = /^\w{3,12}$/;

            var flag = reg_username.test(username);

            var s_username = document.getElementById("s_username");
            if (flag) {

                s_username.innerHTML = "<img width='30' height='20' src='../images/对勾提示.jpg'>"
            } else {

                s_username.innerHTML = "用户名或密码错误！";
            }
            return flag;
        }




        function checkUsername4() {

            var newusername = document.getElementById("newusername").value;

            var reg_username1 = /^\w{3,12}$/;

            var flag1 = reg_username1.test(newusername);

            var s_newusername = document.getElementById("s_newusername");
            if (flag1) {

                s_newusername.innerHTML = "<img width='30' height='20' src='../images/对勾提示.jpg'>"
            } else {

                s_newusername.innerHTML = "请填写完所有项目，并保证格式正确！";
            }
            return flag1;
        }
    </script>

    <script>

    </script>


</body>

</html>